// pages/classify/classify.js
Page({

  data: {
      classify: [],
      goods: [],
      sort: 1
  },

  onLoad: function (options) {
    this.setClassify()
    
    let that = this
    //请求轮播图
    wx.request({
     url: 'http://120.79.28.228:5000/main_key',
      success(res){
        // console.log(res.data)
        that.setData({
          goods: res.data
        })
      }})
    
  },
  //更改类型
  changeSort(event){
    // console.log(event.currentTarget.dataset.sort)
    this.setData({
      sort: event.currentTarget.dataset.sort
    })
  },
  //初始化分类数据
  setClassify(){
    this.setData({
      classify: [
        {
          id: 1,
          title: '手机产品'
        },
        {
          id: 2,
          title: '时尚耳机'
        },
        {
          id: 3,
          title: 'mini相机'
        },
        {
          id: 4,
          title: '电脑硬盘'
        },
        {
          id: 5,
          title: '鼠标键盘'
        },
        {
          id: 6,
          title: '平板电脑'
        }
      ]
    })
  }
})